﻿@using System.Collections
@using Projectmanagement.Entity
@using ProjectManagement.Models
@model IQueryable<Project>
@{
    ViewBag.Title = "Task";
    
    
}
@Html.Hidden("jibie", Employee.CurrentRoleLVL)
@Html.Hidden("hidProject")
@Html.Hidden("hidMember")
@(Html.Telerik().Grid<_Task>()
        .Name("OverdueTask").HtmlAttributes(new { @class = "taskindex" })
    .DataKeys(keys => { keys.Add(item => item.ID); })
    .ClientEvents(events => events.OnEdit("onEdit")
                //.OnDataBinding("Grid_onDataBinding")
        //    .OnLoad("Grid3_onLoad")
            )
    .ToolBar(toolBar => toolBar.Template(
                                    @<text>
<label for="type">
    过期任务</label>

</text>
                                                                                         ))
                                                         .DataBinding(dataBinding =>
                                                         {
                                                             dataBinding.Ajax()
                                                                 .Select("_SelectOverdueTaskIndex", "ProjectTaskProcess")
                                                                 .Insert("_InsertAjaxEditing", "ProjectTaskProcess");
                                                         })
                                                         .Columns(columns =>
                                                         {
                                                             columns.Bound(item => item.Ttype).Hidden();
                                                             columns.Bound(item => item.ProjectCode);
                                                             columns.Bound(item => item.Name).Width(240);
                                                             columns.Bound(item => item.StartDate).Width(140);
                                                             columns.Bound(item => item.EndDate).Width(140);
                                                             columns.Bound(item => item.Duration).Width(120);
                                                             columns.Bound(item => item.Owners).Width(140);
                                                             //columns.Bound(item => item.Complement).Width(120);
                                                             columns.Bound(item => item.Assinger).Width(120);
                                                             columns.Bound(c => c.ID)
                                                                     .ClientTemplate("<a class='t-button' onclick='showtask(<#= ID #>)'>编辑</a>")
                                                                     .Title("操作").Width(100);
                                                         })
                                                         .Editable(editing => editing.Mode(GridEditMode.PopUp))
                                                         .Pageable(paging => paging.Style(GridPagerStyles.Status).PageOnScroll(true))
                                                         .Scrollable(c => c.Height("353px"))
                                                         .Sortable()
                                                         .Resizable(resizing => resizing.Columns(true))
                                                           )
<script type="text/javascript">

    function Grid_onDataBinding(e) {
        var conferenceid = $("#hidProject").val();
        var member = $("#hidMember").val();
        e.data = {
            conferenceid: conferenceid,
            member: member

        };
    }

    function showtask(id) {
        $.post('Task/GetDetail/', { taskid: id }, function (result) {
            $('.TastMessage-wrapper').html(result);
            var window = $('#TastMessage').data('tWindow');
            window.center().open();
        });
    }

    $(document).ready(function () {
        //initialProjectMemberfilter();

        $(".projectfilter").change(function () {
            $("#hidProject").val($(this).closest(".projectfilter").val());
            $(this).closest(".taskindex").data("tGrid").ajaxRequest();
        });

        $(".memberfilter").change(function () {
            var memberValue = $(this).closest(".memberfilter").find("option:selected")[0].text;
            $("#hidMember").val(memberValue);
            $(this).closest(".taskindex").data("tGrid").ajaxRequest();
        });
    });
    function onEdit(e) {

    }

   
</script>
